package org.logsin37.tool.eurekamanager.domain.service;

import org.logsin37.tool.eurekamanager.domain.entity.Eureka;
import org.logsin37.tool.eurekamanager.domain.entity.EurekaApplication;
import org.logsin37.tool.eurekamanager.domain.entity.EurekaInstance;
import org.logsin37.tool.eurekamanager.infra.constant.EurekaInstanceStatus;
import org.logsin37.tool.eurekamanager.infra.remote.EurekaRemoteClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * Eureka Remote Domain Service
 *
 * @author logsin37 2020/01/20 23:29
 */
public interface EurekaRemoteDomainService {

    /**
     * 注册Eureka
     *
     * @param eureka eureka信息
     */
    void register(Eureka eureka);

    /**
     * 注销Eureka
     *
     * @param eurekaCode Eureka代码
     * @return 被注销的eureka client信息
     */
    EurekaRemoteClient unregister(String eurekaCode);

    /**
     * 获取所有的Eureka Application
     *
     * @param eurekaCode Eureka代码
     * @return 所有的Eureka Application
     */
    Flux<EurekaApplication> listAllApplications(String eurekaCode);

    /**
     * 更改指定Eureka实例的状态
     *
     * @param eurekaCode Eureka代码
     * @param instance 实例, app/instanceId不能为空
     * @param status 目标状态
     * @return 修改结果
     */
    Mono<Void> putStatus(String eurekaCode, EurekaInstance instance, EurekaInstanceStatus status);

}
